package XMFramework.Interface.Architechture
{
	import XMFramework.Interface.IFramework;
	import XMFramework.Interface.IModule;

	public class SMModel
	{		
		/**
		 * Pointer to singleton SNS framework object 
		 */		
		public var coreSNSFramework : IFramework;
		
		/**
		 * Reference pointer to collerate view tire 
		 * @return 
		 * 
		 */		
		public var viewLayer : SMView	=	null;
		
		/**
		 * Reference pointer to collerate command tire  
		 * @return 
		 * 
		 */		
		public var commandLayer : SMController	=	null;
		
		/**
		 * Reference pointer to own module object
		 * @return 
		 * 
		 */		
		public var modulePtr : IModule;
		
		/**
		 * 
		 * @param varName
		 * @param params
		 * 
		 */		
		MVCLayerCommand function setAttribute( varName : String, ...params ) : void
		{
			use namespace MVCLayerModel;
			use namespace MVCLayerView;
			
			// Check model has variable set function
			if( this.hasOwnProperty( "set_" + varName ) )
				
				// Send new data to model layer
				(this["set_" + varName] as Function).apply( null, params );
			
			// Update data to view layer				
			if( viewLayer )
				
				// Check model has variable get function and view has variable update function
				if( viewLayer.hasOwnProperty( "update_" + varName ) )
					
					(viewLayer["update_" + varName] as Function).apply( null, params );
				
		}
		
		/**
		 * 
		 * 
		 */		
		public function onRegisterCompleted() : void
		{
			
		}
		
		/**
		 * decrease reference to free memory 
		 * 
		 */
		public function cleanModel():void
		{
			
		}
	}
}